package com.atguigu03.reflectapply.apply1;

import org.junit.Test;

import java.lang.reflect.Method;
import java.sql.SQLOutput;

/**
 * ClassName: MethodsTest
 * Package: com.atguigu03.reflectapply.apply1
 * Description:
 *
 * @Author BuTang
 * @Create 2023/6/25 10:06
 * @Version 1.0
 */
public class MethodsTest {
    @Test
    public void test() throws Exception {

        Class clazz = User.class;


        User user = (User) clazz.newInstance();
        Method[] declaredMethods = clazz.getDeclaredMethods();

        for (Method a:declaredMethods
             ) {

            // 注解 权限修饰符 返回值类型 方法名(形参类型1 参数1,形参类型2 参数2,...) throws 异常类型1,...{}
            //注解
            System.out.println(a.getAnnotations());
            //权限修饰符
            System.out.println(a.getModifiers());
            //方法名
            System.out.println(a.getName());

            //形参列表
            Class[] parameterTypes = a.getParameterTypes();
            for (Class b: parameterTypes
                 ) {System.out.print("形参列表");
                System.out.println(b);

            }


            System.out.println(a);
            System.out.println();
        }

        //getDeclaredMethod方法后面填写的是方法的类型，
        Method show = clazz.getDeclaredMethod("show");
        show.invoke(user);



    }
}
